package com.filldream.fastboot.base.request.pc.redisController;

import com.filldream.fastboot.common.constant.FinalStr;
import com.filldream.fastboot.common.entity.ErrorCode;
import com.filldream.fastboot.common.util.Assert;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;

@Data
public class AddRedisSTO {

    @NotEmpty
    @ApiModelProperty(value = "缓存key")
    private String key;

    @ApiModelProperty(value = "缓存key-type")
    private String type;

    @ApiModelProperty(value = "缓存key-ttl，需单独设置")
    private Long ttl;

    private Integer index;

    private String value;

    private String field;

    @ApiModelProperty(value = "值，list 传入")
    private String member;

    private String element;

    private Double score;

    private Boolean isLeft = true;


    public String checkKey(){
        Assert.isBoolean( !key.contains(FinalStr.getProject_name()), ErrorCode.PARAM_ERR.reMsg("不存在这个Key") );
        Assert.isBoolean( key.equals("*"),ErrorCode.PARAM_ERR.reMsg("违法key") );
        return this.key;
    }

}
